package org.display.util
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.filesystem.File;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.*;
	
	import mx.flash.UIMovieClip;
	
	import org.data.*;
	import org.display.graphic.*;
	import org.display.graphic.line.RotLine;
	import org.utils.*;
	
	public class ShowHistory
	{
		var num:Number=0
		var ivcOld:IvHistory
		
		var workspace:String=""
		
		public function ShowHistory(path,tab,scene,sceneTab,historyScene)
		{

			workspace=path
				
			
			var xmlFile:File=File.documentsDirectory.resolvePath(path.replace(/\\/gis,"/"))
				
			
			if(xmlFile.exists == false){return;}	
			
			loadxml(xmlFile,tab,scene,sceneTab,historyScene)
			
			//Global.selectPath=""
			
			Global.historyJsflsPath=[]
			
		}
		
		
		function loadxml(file,tab,scene,sceneTab,historyScene){
			
			var files:Array=file.getDirectoryListing() 
			
			for(var i=0;i<files.length;i++){
				
				//trace(files[i].url)
				
				if(files[i].isDirectory){
					
					loadxml(files[i],tab,scene,sceneTab,historyScene)
					
				}else if(files[i].url.indexOf("/xml/")==-1){
				
				
				}else{
					
					//Global.selectPath=files[i].url
					
					setTimeout(function(path,tab,scene,sceneTab,workspace){
						
						var ivc:IvHistory=new IvHistory(path,tab,scene,sceneTab,workspace)
						
						historyScene.addChild(ivc);
						
						Global.historyJsflsPath.push({iv:"",ivc:ivc,path:path.replace(/\/xml\//gis,"\/jsfl\/").replace(/\.xml/gis,".jsfl"),ivname:path.split("\/")[path.split("\/").length-1].replace(/\.xml/gis,"")})
						
						if(ivcOld==null){
							ivc.x=0;ivc.y=0;}
						else{
							var rec:Rectangle=ivcOld.getBounds(ivcOld.parent)
							ivc.x=ivcOld.x+rec.width
							ivc.y=ivcOld.y
						}	
						
						ivcOld=ivc
						
						
					},num+=200,files[i].url.replace(/\\/gis,"\/"),tab,scene,sceneTab,workspace)
					
				}
			}
			
			
			//setTimeout(orderY,num+3000)
			
		}
		
		
	}
}